using System;
using System.IO;
using Microsoft.Coding4Fun.TweetCraft.Tray.Support;
using NUnit.Framework;

namespace Microsoft.Coding4Fun.TweetCraft.Tests.Support
{
	[TestFixture]
	public class ZipperTest
	{
		private readonly string currentDirectory = Environment.CurrentDirectory;

		#region SetUp

		[SetUp]
		public void SetUp()
		{

		}

		#endregion

		#region TearDown

		[TearDown]
		public void TearDown()
		{

		}

		#endregion

		#region Tests

		[Test(Description = "")]
		public void TestCompressing()
		{
			const string zipFileName = "zipper.zip";
			if (!Directory.Exists(Path.Combine(currentDirectory, "Resources\\Unzipped")))
				Directory.CreateDirectory(Path.Combine(currentDirectory, "Resources\\Unzipped"));
			foreach (var file in Directory.GetFiles(Path.Combine(currentDirectory, "Resources\\Unzipped"), "*.*", SearchOption.TopDirectoryOnly))
			{
				File.Delete(file);
			}

			string[] files = Directory.GetFiles(Path.Combine(currentDirectory, "Resources"), "*.*", SearchOption.AllDirectories);
			Zipper.Compress(files, Path.Combine(currentDirectory, zipFileName));
            Zipper.Uncompress(Path.Combine(currentDirectory, zipFileName), Path.Combine(currentDirectory, "Resources\\Unzipped"));
			string[] zippedFiles = Directory.GetFiles(Path.Combine(currentDirectory, "Resources\\Unzipped"), "*.*", SearchOption.TopDirectoryOnly);
			Assert.AreEqual(3, zippedFiles.Length);
		}

		#endregion
	}
}